<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<?php
/* 新闻信息添加处理页 */
require_once("../../conn/conn_db.php");   //包含数据库连接文件
if( $_POST["txt_title"]!= "" && $_POST["txt_parentid"]!= "" )  //判断新闻标题及所属栏目是否为空
{
    $ntid = $_POST["txt_parentid"];    //所属类别编号
    $title = $_POST["txt_title"];      //新闻标题
    $intro = $_POST["txt_intro"];      //摘要
    $contents = $_POST["txt_contents"];//内容
    $createtime = date('Y-m-d'); //发布日期
    
    $sql = "insert into news_info (nt_id,n_name,n_intro,n_contents,n_hits,n_createtime,n_status,n_image) values($ntid,'$title','$intro','$contents',66,'$createtime','1','news_image/blog-3.png')";
    $insert = $conn->query($sql); //执行SQL语句
    if($insert)                  //判断执行结果
    {
        echo "<script>alert('新闻信息添加成功！');self.location='../news_add.php'</script>";
    }
    else
    {
        echo "<script>alert('新闻信息添加失败！');self.location='../news_add.php'</script>";
    }
}
else
{
    echo "<script>alert('所属类别和新闻标题不能为空！');self.location='../news_add.php'</script>";
}
?>
</body>
</html>